package com.yan.control;

import com.yan.pojo.Student;
import com.yan.service.AdminService;
import com.yan.service.StudentService;
import com.yan.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;

@Controller
public class StudentController {

    @Autowired
    private StudentService studentService;
    @Autowired
    private AdminService adminService;

    @RequestMapping("/saveStudentByStudent")
    @ResponseBody
    public Msg saveStudentByStudent(@Valid Student student){
        boolean b = studentService.updateStudent02(student);
        return b ? Msg.success() : Msg.fail();
    }

    @RequestMapping("/updateStuPwd")
    @ResponseBody
    public Msg updateStuPwd(@RequestParam("studentId") String studentId,@RequestParam("password")String password){
        boolean b = studentService.updatePassword(Integer.parseInt(studentId), password);
        return b ? Msg.success() : Msg.fail();
    }




}
